#include "stackWidget.h"
#include <QtGui>

stackWidget::stackWidget()
{
	//创造垂直布局
	QVBoxLayout *vLay = new QVBoxLayout();

	//创造下拉列表
	QComboBox *comboBox = new QComboBox();
	//给列表添加内容
	comboBox->addItem("one", 1);
	comboBox->addItem("two", 1);
	comboBox->addItem("three", 1);

	QStackedWidget *stack = new QStackedWidget();
	QTextEdit *text1 = new QTextEdit("one");
	QTextEdit *text2 = new QTextEdit("two");
	QTextEdit *text3 = new QTextEdit("three");

	stack->addWidget(text1);
	stack->addWidget(text2);
	stack->addWidget(text3);

	connect(comboBox, SIGNAL(currentIndexChanged(int)), stack, SLOT(setCurrentIndex(int)));
	vLay->addWidget(comboBox);
	vLay->addWidget(stack);

	setLayout(vLay);
}
